package com.ls.controller.benefit;

import com.ls.controller.benefit.model.AddBenefitModel;
import com.ls.controller.benefit.model.EditBenefitModel;
import com.ls.controller.benefit.model.SortBenefitModel;
import com.ls.service.IBenefitService;
import com.ls.utils.ResultData;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@Api(value = "权益相关PC接口", tags = "权益相关PC接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/benefit")
public class BenefitController {
    private final IBenefitService service;
    /** 权益列表 */
    @GetMapping("getPaging")
    public ResultData getPaging() {
        return service.getPaging();
    }
    /** 新增权益 */
    @PostMapping("add")
    public ResultData add(@Valid @RequestBody AddBenefitModel model) {
        return service.add(model);
    }
    /** 编辑权益 */
    @PostMapping("edit")
    public ResultData edit(@Valid @RequestBody EditBenefitModel model) {
        return service.edit(model);
    }
    /** 权益排序 */
    @PostMapping("sort")
    public ResultData sort(@Valid @RequestBody SortBenefitModel model) {
        return service.sort(model);
    }
    /** 删除权益  */
    @PostMapping("del")
    public ResultData del(@RequestParam @NotNull(message = "id不得为空") Integer benefitId) {
        return service.del(benefitId);
    }
}
